package com.vzoom.logdesensitization.strategyimpl;

import com.vzoom.logdesensitization.DesensitizationStrategy;
import com.vzoom.logdesensitization.util.StarUtil;

public class CompanyDesensitizationStrategy implements DesensitizationStrategy {
    @Override
    public String desensitization(Object origin) {
        String toString = String.valueOf(origin);
        if (origin == null) {
            return toString;
        }
        int length = toString.length();
        if (length <= 3) {
            return StarUtil.getStar(length);
        } else {
            int mod = length / 3;
            return toString.substring(0, mod)
                    + StarUtil.getStar(length - (mod) * 2)
                    + toString.substring(length - mod, length);
        }
    }
}
